package com.ayoka.adapter;

import com.ayoka.R;
import com.ayoka.mvp.TrainingDetailMVP.TrainingDetailModel.TrainingQuestionOptionBean;
import com.ayoka.mvp.TrainingPrepareMVP.TrainingPrepareModel.TrainingQuestionMultiEntity;
import com.jcp.baselibrary.brvah.BaseMultiItemQuickAdapter;
import com.jcp.baselibrary.brvah.BaseViewHolder;

import java.util.List;

/**
 * Created by jinchunping on 2018/4/11.
 */

public class TrainingQuestionOptionMultiAdapter extends BaseMultiItemQuickAdapter<TrainingQuestionMultiEntity, BaseViewHolder> {

    public TrainingQuestionOptionMultiAdapter() {
        super(null);
        addItemType(TrainingQuestionMultiEntity.TITLE, R.layout.multi_item_training_prepare_title);
        addItemType(TrainingQuestionMultiEntity.QUESTION, R.layout.multi_item_training_prepare_question);
        addItemType(TrainingQuestionMultiEntity.OPTION, R.layout.multi_item_training_prepare_option);
        addItemType(TrainingQuestionMultiEntity.BUTTON, R.layout.multi_item_training_prepare_button);
    }

    @Override
    protected void convert(BaseViewHolder holder, TrainingQuestionMultiEntity item) {
        if (item.getItemType() == TrainingQuestionMultiEntity.TITLE){
            holder.setText(R.id.tv_title, (int) item.getData());
        } else if (item.getItemType() == TrainingQuestionMultiEntity.QUESTION){
            holder.setText(R.id.tv_message, (String) item.getData());
        } else if (item.getItemType() == TrainingQuestionMultiEntity.OPTION){
            TrainingQuestionOptionBean optionBean = (TrainingQuestionOptionBean) item.getData();
            holder.setText(R.id.tv_option_title, optionBean.Option);
        } else if (item.getItemType() == TrainingQuestionMultiEntity.BUTTON){
            holder.setText(R.id.btn_start_haba_meditation, R.string.start_haba_meditation);
            holder.addOnClickListener(R.id.btn_start_haba_meditation);
        }
    }
}
